package com.lws.basic.base;

import android.os.Bundle;

/**
 * @松 on 2019/6/8 21:07
 */
public abstract class BaseMvpFragment <P extends BaseMvpPresenter > extends BaseFragment {
    private P mPresenter;

    @Override
    public void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (mPresenter== null) {
            mPresenter = createPresenter();
            mPresenter.attachView(this);
        }
    }

    @Override
    public void onDestroyView() {
        if (mPresenter != null) {
            mPresenter.detachView();
            System.gc();
        }
        super.onDestroyView();
    }

    protected abstract P createPresenter();
}
